Skip to content

Refresh OAuth2 tokens when expired#5

Merged
jjmerchante merged 1 commit intobitergia-analytics:mainfrom
sduenas:expired_oauth_tokens
Sep 19, 2025
Merged

Refresh OAuth2 tokens when expired#5
jjmerchante merged 1 commit intobitergia-analytics:mainfrom
sduenas:expired_oauth_tokens

Conversation

@sduenas
Copy link
Copy Markdown
Contributor

@sduenas sduenas commented Sep 17, 2025

The importer was raising 403 errors when the OAuth2 token expired. This patch refreshes the token and
retries to fetch again the data.

return response.json()
elif response.status_code == 403:
# Refresh token if needed and try again
if self.token_oauth.expires_at <= datetime_utcnow():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be self.token.expires_at?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@sduenas sduenas force-pushed the expired_oauth_tokens branch 2 times, most recently from 7f09bb2 to 5d251f3 Compare September 19, 2025 09:42
The importer was raising 403 errors when the OAuth2
token expired. This patch refreshes the token and
retries to fetch again the data.

Signed-off-by: Santiago Dueñas <sduenas@bitergia.com>
@sduenas sduenas force-pushed the expired_oauth_tokens branch from 5d251f3 to 6e217c3 Compare September 19, 2025 09:54
Copy link
Copy Markdown
Contributor

@jjmerchante jjmerchante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jjmerchante jjmerchante merged commit abd3660 into bitergia-analytics:main Sep 19, 2025
5 checks passed
@sduenas sduenas deleted the expired_oauth_tokens branch September 19, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants